<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ page import="com.db.conn"%>
<%@ page import="com.db.Pagination"%>
<%@ page import="java.sql.*"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

<html xmlns="http://www.w3.org/1999/xhtml">
  <head>
<jsp:include flush="true" page="${basePath}/admin/head.jsp"></jsp:include>
    <style>
        .ms-panel {
            margin: 0;
            padding: 0;
            background: #fff;
            border-radius: 4px;
            box-shadow: 0 1px 3px rgba(0,0,0,0.12);
        }
        
        .ms-panel-header {
            padding: 20px 24px;
            border-bottom: 1px solid #eee;
            display: flex;
            justify-content: space-between;
            align-items: center;
        }
        
        .ms-panel-header h6 {
            margin: 0;
            font-size: 18px;
            font-weight: 500;
            color: #333;
        }
        
        .ms-panel-body {
            padding: 24px;
        }
        
        .search-form {
            margin-bottom: 24px;
            padding: 20px;
            background: #f8f9fa;
            border-radius: 4px;
        }
        
        .search-form .form-group {
            display: inline-block;
            margin-right: 15px;
            margin-bottom: 0;
        }
        
        .search-form label {
            margin-right: 8px;
            color: #666;
            font-weight: 500;
        }
        
        .search-form input {
            width: 180px;
            height: 36px;
            padding: 0 12px;
            border: 1px solid #ddd;
            border-radius: 4px;
            transition: all 0.3s;
        }
        
        .search-form input:focus {
            border-color: #007bff;
            box-shadow: 0 0 0 0.2rem rgba(0,123,255,.25);
        }
        
        .btn-search {
            height: 36px;
            padding: 0 20px;
            background: #007bff;
            color: #fff;
            border: none;
            border-radius: 4px;
            cursor: pointer;
            transition: all 0.3s;
        }
        
        .btn-search:hover {
            background: #0056b3;
        }
        
        .table-responsive {
            margin-bottom: 24px;
        }
        
        .table {
            width: 100%;
            margin-bottom: 0;
            background-color: transparent;
            border-collapse: collapse;
        }
        
        .table th {
            background: #f8f9fa;
            color: #333;
            font-weight: 500;
            padding: 12px 8px;
            border-bottom: 2px solid #dee2e6;
            text-align: center;
        }
        
        .table td {
            padding: 12px 8px;
            vertical-align: middle;
            border-bottom: 1px solid #dee2e6;
            text-align: center;
        }
        
        .table tr:hover {
            background-color: #f8f9fa;
        }
        
        .user-avatar {
            width: 40px;
            height: 40px;
            border-radius: 50%;
            object-fit: cover;
            border: 1px solid #ddd;
        }
        
        .btn-action {
            padding: 4px 12px;
            font-size: 13px;
            border-radius: 4px;
            text-decoration: none;
            transition: all 0.3s;
            margin: 0 4px;
        }
        
        .btn-detail {
            background: #17a2b8;
            color: #fff;
        }
        
        .btn-delete {
            background: #dc3545;
            color: #fff;
        }
        
        .btn-action:hover {
            opacity: 0.9;
        }
        
        .pagination {
            margin: 24px 0 0;
            padding: 0;
            display: flex;
            justify-content: center;
            align-items: center;
            list-style: none;
            gap: 8px;
        }
        
        .pagination li {
            margin: 0;
        }
        
        .pagination a {
            display: inline-flex;
            align-items: center;
            justify-content: center;
            min-width: 40px;
            height: 40px;
            padding: 0 12px;
            border: 1px solid #e0e0e0;
            border-radius: 8px;
            color: #666;
            text-decoration: none;
            transition: all 0.3s ease;
            font-size: 14px;
            background: #fff;
            box-shadow: 0 1px 3px rgba(0,0,0,0.05);
        }
        
        .pagination a:hover {
            background: #f8f9fa;
            border-color: #d0d0d0;
            color: #333;
            transform: translateY(-2px);
            box-shadow: 0 4px 8px rgba(0,0,0,0.1);
        }
        
        .pagination .active a {
            background: #007bff;
            border-color: #007bff;
            color: #fff;
            font-weight: 600;
            box-shadow: 0 4px 8px rgba(0,123,255,0.3);
        }
        
        .pagination .disabled a {
            color: #999;
            background: #f8f9fa;
            border-color: #e0e0e0;
            cursor: not-allowed;
            opacity: 0.7;
        }
        
        .pagination .prev a,
        .pagination .next a {
            padding: 0 16px;
            font-weight: 500;
            background: #f8f9fa;
            min-width: 100px;
        }
        
        .pagination .prev a:before {
            content: "←";
            margin-right: 8px;
            font-size: 16px;
            font-weight: bold;
        }
        
        .pagination .next a:after {
            content: "→";
            margin-left: 8px;
            font-size: 16px;
            font-weight: bold;
        }
        
        .pagination .prev a:hover,
        .pagination .next a:hover {
            background: #fff;
            transform: translateY(-2px);
        }
    </style>
  </head>

  <body class="ms-body ms-aside-left-open ms-primary-theme ms-has-quickbar">
    <div class="ms-content-wrapper">
        <div class="row">
            <div class="col-md-12">
                <div class="ms-panel">
                    <div class="ms-panel-header">
                        <h6>用户管理</h6>
                    </div>
                    <div class="ms-panel-body">
                        <div class="search-form">
                            <form action="<%=path %>/admin/member/member_Manage.jsp" method="post">
                                <div class="form-group">
                                    <label>微信昵称:</label>
                                    <input name="txt_nic" type="text" id="txt_nic" />
                                </div>
                                <div class="form-group">
                                    <label>姓名:</label>
                                    <input name="txt_mname" type="text" id="txt_mname" />
                                </div>
                                <div class="form-group">
                                    <label>手机号码:</label>
                                    <input name="txt_tel" type="text" id="txt_tel" />
                                </div>
                                <button type="submit" name="search" class="btn-search">查询</button>
                            </form>
                        </div>

                        <%
                            int pageSize = 15;
                            int pageNow = 1;
                            int rowCount = 0;
                            int pageCount = 0;
                            String s_pageNow = request.getParameter("pageNum");
                            if(s_pageNow != null) {
                                pageNow = Integer.parseInt(s_pageNow);
                            }

                            String where = " 1=1 ";
                            if(request.getParameter("txt_nic") != null) {
                                where += " and nic like '%" + request.getParameter("txt_nic") + "%' ";
                            }
                            if(request.getParameter("txt_mname") != null) {
                                where += " and mname like '%" + request.getParameter("txt_mname") + "%' ";
                            }
                            if(request.getParameter("txt_tel") != null) {
                                where += " and tel like '%" + request.getParameter("txt_tel") + "%' ";
                            }

                            conn cn = new conn();
                            ResultSet rs = cn.query("select count(*) from member a where " + where);
                            if(rs.next()) {
                                rowCount = rs.getInt(1);
                            }

                            if(rowCount % pageSize == 0) {
                                pageCount = rowCount / pageSize;
                            } else {
                                pageCount = rowCount / pageSize + 1;
                            }

                            rs = cn.query("select * from member a where " + where + " order by mid desc limit " + pageSize * (pageNow - 1) + ", " + pageSize);
                        %>

                        <div class="table-responsive">
                            <table class="table">
                                <thead>
                                    <tr>
                                        <th>微信昵称</th>
                                        <th>微信头像</th>
                                        <th>姓名</th>
                                        <th>性别</th>
                                        <th>年龄</th>
                                        <th>手机号码</th>
                                        <th>注册时间</th>
                                        <th>操作</th>
                                    </tr>
                                </thead>
                                <tbody>
                                    <% while(rs.next()) { %>
                                    <tr>
                                        <td><%=rs.getString("nic") %></td>
                                        <td>
                                            <img src="<%=rs.getString("photo") %>" alt="用户头像" class="user-avatar" />
                                        </td>
                                        <td><%=rs.getString("mname") %></td>
                                        <td><%=rs.getString("sex") %></td>
                                        <td><%=rs.getString("age") %></td>
                                        <td><%=rs.getString("tel") %></td>
                                        <td><%=rs.getString("atime") %></td>
                                        <td>
                                            <a href="<%=path %>/admin/member/member_Detail.jsp?id=<%=rs.getString("mid") %>" class="btn-action btn-detail">详细</a>
                                            <a href="<%=path %>/member_Delete?id=<%=rs.getString("mid") %>" class="btn-action btn-delete" onclick="return confirm('确定要删除该用户吗？')">删除</a>
                                        </td>
                                    </tr>
                                    <% } %>
                                </tbody>
                            </table>
                        </div>

                        <div class="pagination">
                            <%= Pagination.getPagination(pageNow, pageCount, rowCount, request.getRequestURI()) %>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</body>
</html>







